#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
typedef struct DATA
{
    /* data */
    unsigned char head_type;
    unsigned short len;
    unsigned char data[1];
}__attribute__ ((__packed__)) DATA;

int main(){
    printf("=== current operatertion");
    int fd = open("./myfifo",O_RDWR);
    if(fd < 0){
        perror("open");
        return -1;
    }
    unsigned char buf[100]={'\0'};
    unsigned char c_char='\0';
    int i = 0;
    while(1){
        read(fd,&c_char,1);
        buf[i++]=c_char;
        if(i==buf[1]-1) break;
    }
    for(i = 0;i < buf[1];i++){
        printf("%x ",buf[i]);
    }
    printf("\n");
    DATA *recvmsg=(DATA *)buf;
    printf("%s\n",recvmsg->data);
    close(fd);
    return 0;
}
